package com.util;

import lombok.Data;

/**
 * Author：hanll
 * ClassName：Result
 * Date：2022/10/22 19:43
 * Version：1.0
 * Description：
 */
@Data
public class Result <T>{

    private Integer code;

    private String message;

    private T data;

    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result(String message) {
        this.message = message;
        this.code = 500;
    }

    public Result(Integer code, String message) {
        this.message = message;
        this.code = code;
    }

    public static Result success() {
        return new Result(200, "success");
    }

    public static Result success(Object data) {
        return new Result(200, "success", data);
    }

    public static Result error(String message) {
        return new Result(message);
    }
}
